package com.lxp.basic.继承案例发红包;

import java.util.List;
import java.util.Random;

/**
 * @ClassName Mbmber
 * @Aauthor swd
 * @Create 2019-12-04 14:02
 */


public class Member extends User {

    public Member() {
    }

    public Member(String userName, double leftMoney) {
        super(userName, leftMoney);
    }

    //打开红包，就是从集合中，随机取出一份，保存到自己余额
    public void open(List<Double> list){
        Random random = new Random();
        //随机生成一个角标
        int index = random.nextInt(list.size());
        //移除一个金额
        Double money = list.remove(index);
        setLeftMoney(money);
    }

}
